# -*- coding:utf-8
"""
作者: Jia
日期: 2022年04月19日
描述: https://leetcode-cn.com/problems/largest-perimeter-triangle/
"""
from typing import List


class Solution:
    def largestPerimeter(self, nums: List[int]) -> int:
        nums.sort()
        for i in range(len(nums) - 1, 1, -1):
            if nums[i] < nums[i - 1] + nums[i - 2]:
                return nums[i] + nums[i - 1] + nums[i - 2]
        return 0


s = Solution()
s.largestPerimeter([1, 1, 2])
